package com.dgut.controller;


import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.dgut.common.SelectRole;
import com.dgut.pojo.LegalRecourse;
import com.dgut.pojo.OrderGrabbing;
import com.dgut.service.LegalRecourseService;
import com.dgut.utils.PageRequestInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.concurrent.ConcurrentHashMap;

@CrossOrigin
@Api("ContractController")
@RestController
@RequestMapping("/legalRecourse")
public class LegalRecourseController {
    @Resource
    private LegalRecourseService legalRecourseService;
    /**
     * start-zwb
     */
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "采买方获取法律求助表")
    @PostMapping("/getLegalRecourseListToBuyer")
    public Object getLegalRecourseListToBuyer(@ApiParam(value = "条件",required = true) @RequestBody  LegalRecourse legalRecourse,@ApiParam(value = "当前页码",required = true) @RequestParam Integer pageNum,@ApiParam(value = "每页数量",required = true) @RequestParam Integer pageSize) {
        ConcurrentHashMap map = new ConcurrentHashMap();
        PageRequestInfo pageRequestInfo = new PageRequestInfo(pageNum,pageSize);
        map.put("legalRecourseList", legalRecourseService.getLegalRecourseListToBuyer(pageRequestInfo,legalRecourse));
        return map;
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.SERVICE_PROVIDER)
    @ApiOperation(value = "服务商获取法律求助表")
    @PostMapping("/getLegalRecourseListToServiceProvider")
    public Object getLegalRecourseListToServiceProvider(@ApiParam(value = "分页信息",required = true) @RequestBody PageRequestInfo pageRequestInfo,
                                                        @ApiParam(value = "状态",required = true) @RequestParam String state,
                                                        @ApiParam(value = "标题",required = false) @RequestParam(required = false) String title
                                                        ) {
        ConcurrentHashMap map = new ConcurrentHashMap();
        map.put("legalRecourseList", legalRecourseService.getLegalRecourseListToServiceProvider(pageRequestInfo,title,state));
        return map;
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "通过法律求助id获取抢单表")
    @PostMapping("/getOrderGrabbingList")
    public Object getOrderGrabbingList(@ApiParam(value = "分页信息",required = true) @RequestBody  PageRequestInfo pageRequestInfo,@ApiParam(value = "法律求助id",required = true) @RequestParam Integer id) {
        ConcurrentHashMap map = new ConcurrentHashMap();
        map.put("OrderGrabbingList", legalRecourseService.getOrderGrabbingList(pageRequestInfo,id));
        return map;
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "选择服务商")
    @PostMapping("/selectServiceProvider")
    public Object selectServiceProvider(@ApiParam(value = "抢单id",required = true) @RequestParam Integer id) {
        return legalRecourseService.selectServiceProvider(id);
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.SERVICE_PROVIDER)
    @ApiOperation(value = "新增抢单信息")
    @PostMapping("/addOrderGrabbing")
    public Object addOrderGrabbing(@ApiParam(value = "新增抢单信息",required = true) @RequestBody OrderGrabbing orderGrabbing) {
        return legalRecourseService.grabOrder(orderGrabbing);
    }
    @SaCheckLogin
    @ApiOperation(value = "通过法律求助id获取法律求助")
    @PostMapping("/getLegalRecourseById")
    public Object getLegalRecourseListById(@ApiParam(value = "法律求助id",required = true) @RequestParam Integer id) {
        ConcurrentHashMap map = new ConcurrentHashMap();
        map.put("legalRecourse",legalRecourseService.getLegalRecourseById(id));
        return map;
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "新增法律求助信息")
    @PostMapping("/addLegalRecourse")
    public Object addLegalRecourse(@ApiParam(value = "新增法律求助信息",required = true) @RequestBody LegalRecourse legalRecourse) {
        return legalRecourseService.addLegalRecourse(legalRecourse);
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "修改法律求助信息")
    @PostMapping("/modifyLegalRecourse")
    public Object modifyLegalRecourse(@ApiParam(value = "修改法律求助信息",required = true) @RequestBody LegalRecourse legalRecourse) {
        return legalRecourseService.modifyLegalRecourse(legalRecourse);
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "删除法律求助信息")
    @PostMapping("/deleteLegalRecourse")
    public void deleteLegalRecourse(@ApiParam(value = "法律求助id",required = true) @RequestParam Integer id) {
        legalRecourseService.deleteLegalRecourse(id);
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "发布法律求助")
    @PostMapping("/putOnLegalRecourse")
    public Object putOnLegalRecourse(@ApiParam(value = "法律求助id",required = true) @RequestParam Integer id) {
        return legalRecourseService.putOnLegalRecourse(id);
    }
    @SaCheckLogin
    @SaCheckRole(SelectRole.BUYER)
    @ApiOperation(value = "取消发布法律求助")
    @PostMapping("/takeDownLegalRecourse")
    public Object takeDownLegalRecourse(@ApiParam(value = "法律求助id",required = true) @RequestParam Integer id) {
        return legalRecourseService.takeDownLegalRecourse(id);
    }

    /**
     *
     * end-zwb
     */


    /**
     * start-gxd
     */
    /**
     * end-gxd
     */


    /**
     * start-lzh
     */
    /**
     * end-lzh
     */

    /**
     * start-hwf
     */
    /**
     * end-hwf
     */
}